#include "listwidget.h"

ListWidget::ListWidget()
{

}
void ListWidget::dragEnterEvent(QDragEnterEvent *event)  {
    if (event->mimeData()->hasUrls()) {
        event->acceptProposedAction();
    }
}

void ListWidget::dropEvent(QDropEvent *event) {
    QListWidget::dropEvent(event);
    for (const QUrl &url : event->mimeData()->urls()) {
        QString filePath = url.toLocalFile();
        //qDebug() << "Dropped file:" << filePath;
        if(filePath.endsWith(".txt",Qt::CaseInsensitive))
        {
            addItem(filePath);
        }

    }
    event->acceptProposedAction();
}
